import Vue from 'vue'
import App from './App.vue'
import router from './router'
import store from './store'


Vue.config.productionTip = false;

import axios from 'axios';
Vue.prototype.$axios = axios;

import VueAwesomeSwiper from 'vue-awesome-swiper'

// import style (>= Swiper 6.x)
// import 'swiper/swiper-bundle.css'

// import style (<= Swiper 5.x)
import 'swiper/css/swiper.css'

Vue.use(VueAwesomeSwiper, /* { default options with global component } */)

import Distpicker from 'v-distpicker'

Vue.component('v-distpicker', Distpicker)


new Vue({
  router,
  store,
  render: h => h(App)
}).$mount('#app')

router.beforeEach((to, from, next) => {
  /* console.log(to);
  console.log(from); */
  if (to.meta.requireAuth) { // 判断该路由是否需要登录权限
    if(localStorage.getItem('id')!=null){ //判断本地是否存在access_token
      next();
    }else {
     if(to.path === '/Login'){
        next();
      }else {
        next({
          path:'/Login'
        })
      }
    }
  }
  else {
    next();
  }
});
